package it.unibo.refolding.pico;

import java.nio.file.Path;

import it.unibo.refolding.pico.FileMovingWatcher.FileContentAndTargetFile;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import com.google.common.base.Preconditions;

public class TimedFileContentAndTargetFile {

  public final FileContentAndTargetFile fileContentAndTargetFile;
  public final double probableTimeS, upperBoundTimeS;
  
  public TimedFileContentAndTargetFile(FileContentAndTargetFile fileContentAndTargetFile,
    double probableTimeS, double upperBoundTimeS) {
    this.fileContentAndTargetFile = fileContentAndTargetFile;
    Preconditions.checkArgument(0 <= probableTimeS);
    Preconditions.checkArgument(upperBoundTimeS >= 0);
    this.probableTimeS = probableTimeS;
    Preconditions.checkArgument(probableTimeS <= upperBoundTimeS);
    this.upperBoundTimeS = upperBoundTimeS;
  }
  
  @Override
  public String toString() {
    return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
  }

  public byte[] fileContent() {
    return fileContentAndTargetFile.fileContent;
  }

  public Path targetFile() {
    return fileContentAndTargetFile.targetFile;
  }
}
